from sklearn.tree import DecisionTreeClassifier
import sklearn.datasets as datasets
from sklearn.model_selection import train_test_split

x = datasets.load_iris().data
y = datasets.load_iris().target

x_train, x_test, y_train, y_test = train_test_split(x, y)

# 基尼系数   信息熵
dec_tree = DecisionTreeClassifier(max_depth=2, criterion="gini")
dec_tree.fit(x_train, y_train)
print(dec_tree.score(x_test,y_test))